setTimeout(function(){

	type = identifyUrl();

	if(type == 1){
		btn = shrinkBtn('好货采集');
		html = hhCollectPanel();
		
	}
	if(type == 2 || type == 3){
		btn = shrinkBtn('资源面板');
		html = sourcePubPanel();
	}
	

	
    $('html body').append(btn);
	$('html body').append(html);
	
		
	

  
  
//------------------------------------------事件点击---------------------------------------------------

// 资源发布按钮
$('.source_pub').click(function(){
	that = $('.source_pub_process');
	pub_num = $('.pub_num').val();
	if(!pub_num){
		layer.msg('请输入发布篇数');
		return false;
	}
	//辨识平台 
	type = identifyUrl();
	//头条
	if(type == 2){
		wordsAppend(that,'开始发文，发文间隔为10秒，请耐心等待');
		i = 0;
		tt_pub = setInterval(function(){
					if(i == pub_num){
						wordsAppend(that,'发文完毕,共发'+i+'篇',1);
						clearInterval(tt_pub);
						return false;
					}
					article_data = ttArticle();
					if(!article_data){
						layer.msg('暂无文章可发');
						wordsAppend(that,'暂无文章可发',1);
						clearInterval(tt_pub);
						return false;
					}
					data = ttArticleArrange(article_data);
					flag = ttArticleSubmit(data);
					if(flag == true){
						wordsAppend(that,'文章id:'+article_data.id+'发布成功',1);
						setTimeout(function(){
							res = ttStatusWrite(article_data.id);
							if(res){
								wordsAppend(that,'状态回写成功',1);
							}else{
								wordsAppend(that,'状态回写失败',2);
							}
						})
					}else{
						wordsAppend(that,flag,2);
						clearInterval(tt_pub);
						return false;
					}
					i++;
		        },10000);
	
	}
	
	if(type == 3){
		wordsAppend(that,'开始发文，发文间隔为10秒，请耐心等待');
		i = 0;
		
		qtt_pub = setInterval(function(){
					if(i == pub_num){
						wordsAppend(that,'发文完毕,共发'+i+'篇',1);
						clearInterval(qtt_pub);
						return false;
					}
					article_data = qttArticle();
					if(!article_data){
						layer.msg('暂无文章可发');
						wordsAppend(that,'暂无文章可发',1);
						clearInterval(qtt_pub);
						return false;
					}
					data = qttArticleArrange(article_data);
					
					flag = qttArticleSubmit(data);
					if(flag == true){
						wordsAppend(that,'文章id:'+article_data.id+'发布成功',1);
						setTimeout(function(){
							res = qttStatusWrite(article_data.id);
							if(res){
								wordsAppend(that,'状态回写成功',1);
							}else{
								wordsAppend(that,'状态回写失败',2);
							}
						})
					}else{
						wordsAppend(that,flag,2);
						clearInterval(qtt_pub);
						return false;
					}
					i++;
					
		        },10000);
	
	}
	
	
})

// 缩放按钮点击
$('.btn_shrink').click(function(){
	style = $('.panel').attr('style');
	if(style.indexOf('block') != -1){
		$('.panel').css('display','none');
	}else{
		$('.panel').css('display','block');
	}
})



  

},1500);

function identifyUrl(){
	let url = window.location.href;
	let type = 0;
	if(url.indexOf('market.m.taobao.com') != -1 && url.indexOf('contentId') != -1){
		type = 1;
	}
	
	if(url.indexOf('mp.toutiao.com') != -1 && url.indexOf('login') == -1){
		type = 2;
	}
	
	if(url.indexOf('mp.qutoutiao.net') != -1 && url.indexOf('login') == -1){
		type = 3;
	}
	
	return type;
}

